package com.bzkj.common.constant;

/**
 * @projectName: prt-wms
 * @package: com.bzkj.common.constant
 * @className: OperationType
 * @description: 操作类型
 * @author: C1309
 * @createDate: 2025年03月04日
 * @version: v1.0
 */
public enum OperationType {
    CREATE(1, "新增"),
    UPDATE(2, "更新"),
    DELETE(3, "删除"),
    QUERY(4, "查询"),
    SIGNATURE(5, "签字"),
    CONFIRM(6, "确认"),
    AUDIT(7, "审核"),
    CANCEL(8, "取消"),
    REJECT(9, "拒绝"),
    EXPORT(10, "导出"),
    IMPORT(11, "导入"),
    PRINT(12, "打印"),
    DOWNLOAD(13, "下载"),
    UPLOAD(14, "上传"),
    RESET(15, "重置"),
    RECOVER(16, "恢复"),
    DELETE_FOREVER(17, "永久删除");

    private final int code; // 操作码
    private final String description; // 操作描述

    OperationType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据 code 获取对应的 OperationType
    public static OperationType fromCode(int code) {
        for (OperationType type : OperationType.values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的操作类型代码：" + code);
    }

    @Override
    public String toString() {
        return this.name() + "(" + code + ": " + description + ")";
    }
}
